function t(t, a) {
    var o = this.data.noticeBoard;
    o.showUpgradeDialog = 0, this.setData({
        noticeBoard: o
    });
}

function a(t) {
    f.buttonClicked(this);
    for (var a = this.data.lottoList, o = 0; o < a.length; o++) a[o].right = 0, a[o].isDelShow = !1;
    this.setData({
        toDetail: !0,
        lottoList: a
    });
    var s = t.currentTarget.dataset.id;
    wx.navigateTo({
        url: "/pages/detail/detail?lid=" + s
    });
}

function o() {
    n(this);
}

function s(t) {
    var a = this;
    wx.showModal({
        title: "置顶确认",
        content: "确认要置顶本条抽奖吗？",
        success: function(o) {
            if (o.confirm) {
                var s = t.currentTarget.dataset.index;
                a.setData({
                    top: 1,
                    index: s
                }), n(a);
            }
        }
    });
}

function e(t) {
    if (!this.data.toDetail) {
        var a = t.currentTarget.dataset.index, o = t.currentTarget.dataset.sponsor, s = t.currentTarget.dataset.type;
        this.setData({
            longtap: !0,
            index: a
        });
        var e = this, d = [ "删除抽奖", "设为赞助商" ];
        o && (d = [ "删除抽奖", "取消赞助商", "发送订阅消息" ]), 2 != s && 3 != s || (d = [ "删除抽奖" ]), 
        wx.showActionSheet({
            itemList: d,
            success: function(t) {
                0 == t.tapIndex ? 3 == s ? e.deleteLotto() : wx.showModal({
                    title: "删除确认",
                    content: "确认要删除此抽奖吗？",
                    success: function(t) {
                        t.confirm && i(e);
                    }
                }) : 1 == t.tapIndex ? o ? wx.showModal({
                    title: "取消确认",
                    content: "确认要取消此抽奖的赞助商吗？",
                    success: function(t) {
                        t.confirm && n(e, !0);
                    }
                }) : e.setData({
                    sponsorDialog: !0
                }) : wx.showModal({
                    title: "发送通知确认",
                    content: "确认要发送订阅消息吗？",
                    success: function(t) {
                        t.confirm && c(e);
                    }
                }), e.setData({
                    longtap: !1
                });
            },
            fail: function(t) {
                e.setData({
                    longtap: !1
                });
            }
        });
    }
}

function i(t) {
    f.showLoading("正在删除");
    var a = t.data.index, o = t.data.lottoList, s = o[a].lid;
    wx.request({
        url: p.globalData.host + "/lotto/v1/remove",
        data: {
            access_token: wx.getStorageSync("accessToken"),
            lid: s
        },
        method: "POST",
        success: function(s) {
            f.hideLoading(), -500 != s.data.sta ? 0 == s.data.sta ? (f.showToast("删除成功"), o.splice(a, 1), 
            t.setData({
                lottoList: o
            })) : f.showFailedToast("删除失败", s.data.msg) : f.login(function() {
                i(t);
            });
        },
        fail: function(t) {
            f.hideLoading(), f.showFailedToast("删除失败");
        }
    });
}

function n(t, a) {
    f.showLoading("正在提交数据");
    var o = t.data.index, s = t.data.lottoList, e = s[o].lid, n = "", c = "", d = "";
    a || (n = s[o].sponsor || t.data.sponsor, c = s[o].appid || t.data.appid, d = s[o].path || t.data.path), 
    wx.request({
        url: p.globalData.host + "/lotto/v1/sponsor/update",
        data: {
            access_token: wx.getStorageSync("accessToken"),
            lid: e,
            sponsor: n,
            appid: c,
            path: d,
            top: t.data.top ? 1 : 0
        },
        method: "POST",
        success: function(o) {
            f.hideLoading(), -500 != o.data.sta ? 0 == o.data.sta ? (a ? f.showToast("取消成功") : f.showToast("设置成功"), 
            t.setData({
                sponsorDialog: !1
            }), t.data.top && (t.setData({
                type: 5,
                page: 1,
                moreData: !0,
                top: 0
            }), t.successCb(t))) : a ? f.showFailedToast("取消失败", o.data.msg) : f.showFailedToast("设置失败", o.data.msg) : f.login(function() {
                i(t);
            });
        },
        fail: function(t) {
            f.hideLoading(), f.showFailedToast("网络超时，请重试");
        }
    });
}

function c(t) {
    f.showLoading("正在发送通知");
    var a = t.data.index, o = t.data.lottoList[a].lid;
    wx.request({
        url: p.globalData.host + "/lotto/v1/sponsor/notice",
        data: {
            access_token: wx.getStorageSync("accessToken"),
            lid: o
        },
        method: "POST",
        success: function(a) {
            f.hideLoading(), -500 != a.data.sta ? 0 == a.data.sta ? f.showToast("通知发送成功") : f.showFailedToast("通知发送失败", a.data.msg) : f.login(function() {
                c(t);
            });
        },
        fail: function(t) {
            f.hideLoading(), f.showFailedToast("API请求超时，" + t.errMsg);
        }
    });
}

function d() {
    this.setData({
        huomaDialog: !1
    });
}

function l() {
    var t = this.data.huoma;
    wx.navigateToMiniProgram ? wx.navigateToMiniProgram({
        appId: t.appid
    }) : wx.previewImage({
        urls: [ t.qrcode ]
    }), this.closeHuomaDialog();
}

function r(t) {
    var a = this;
    f.showLoading("正在登录..."), f.buttonLogin(function() {
        f.hideLoading(), a.setData({
            hasUserInfo: !0
        }), console.log("===== typeof"), console.log(h(a.successCb)), "function" == typeof a.successCb && a.successCb();
    }, function() {
        f.hideLoading();
    }, t.detail);
}

function u(t) {
    var a = t.currentTarget.dataset.index, o = this.data.adsList[a], s = this.data.adFrom;
    f.toAdDetail(o, s);
}

function g(t) {
    var a = t.detail.current, o = this.data.adsList[a], s = this.data.adFrom;
    f.adShow(o, s);
}

var h = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(t) {
    return typeof t;
} : function(t) {
    return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : typeof t;
}, f = require("../utils/util.js"), p = getApp();

module.exports = {
    noticeBoard: function(a, o) {
        a.successCb = o, a.closeUpgradeDialog = t;
    },
    enRoll: function(t, i) {
        t.successCb = i, t.toDetail = a, t.longtap = e, t.setSpnsor = o, t.setTop = s;
    },
    huoma: function(t, a) {
        t.successCb = a, t.closeHuomaDialog = d, t.toHuoma = l;
    },
    wxLogin: function(t, a) {
        t.successCb = a, t.login = r;
    },
    ads: function(t, a, o, s) {
        t.successCb = s, t.setData({
            adFrom: o
        }), t.toAdDetail = u, t.swiperChange = g, f.getAds(t, a, o, function() {
            console.log("获取广告请求 555 ： "), "function" == typeof s && s();
        });
    }
};